/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * PanelInstitucion.java
 *
 * Created on May 10, 2010, 3:08:29 AM
 */

package gui;

import com.toedter.calendar.JCalendar;
import entidades.Institucion;
import entidades.PoblacionBeneficiada;
import java.awt.event.ActionEvent;
import java.text.DateFormat;
import java.util.Date;
import javax.swing.JDialog;
import javax.swing.JOptionPane;
import manejadores.ManejadorDeInstitucion;
import manejadores.ManejadorDePoblacionBeneficiada;
import utilidades.Utilidad;

/**
 *
 * @author Snailin
 */
public class PanelInstitucion extends javax.swing.JPanel {
    private Date fechaFundacion;
    private static DateFormat formatoFecha;
    private Utilidad utilidad;
    /** Creates new form PanelInstitucion */
    public PanelInstitucion() {
        initComponents();
        utilidad = new Utilidad();
         fechaFundacion=new Date();
        formatoFecha = DateFormat.getDateInstance();
       
            tabInformacionPersonal.setTitleAt(0, "Informacion Personal");
             tabInformacionPersonal.setTitleAt(1, "Informacion General");

    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        tabInformacionPersonal = new javax.swing.JTabbedPane();
        jPanel1 = new javax.swing.JPanel();
        lblNombre = new javax.swing.JLabel();
        lblRepresentante = new javax.swing.JLabel();
        lblTelefono = new javax.swing.JLabel();
        lblDireccion = new javax.swing.JLabel();
        lblSector = new javax.swing.JLabel();
        lblFechaFundacion = new javax.swing.JLabel();
        txtNombreIntitucion = new javax.swing.JTextField();
        txtRepresentante = new javax.swing.JTextField();
        txtTelefono = new javax.swing.JFormattedTextField();
        txtFechaFundacion = new javax.swing.JTextField();
        btnElegirFecha = new javax.swing.JButton();
        txtSector = new javax.swing.JTextField();
        jScrollPane1 = new javax.swing.JScrollPane();
        txtDireccion = new javax.swing.JTextArea();
        jPanel2 = new javax.swing.JPanel();
        lblRangoEdades = new javax.swing.JLabel();
        txtRangoEdades = new javax.swing.JFormattedTextField();
        lblGenero = new javax.swing.JLabel();
        lblNivelEconomico = new javax.swing.JLabel();
        lblNivelEducativo = new javax.swing.JLabel();
        txtNivelEconomico = new javax.swing.JTextField();
        txtNivelEducativo = new javax.swing.JTextField();
        txtGenero = new javax.swing.JTextField();
        btnAceptar = new javax.swing.JButton();
        btnCancelar = new javax.swing.JButton();

        tabInformacionPersonal.setBorder(javax.swing.BorderFactory.createTitledBorder(""));

        jPanel1.setBackground(new java.awt.Color(204, 204, 204));

        lblNombre.setFont(new java.awt.Font("Agency FB", 0, 14));
        lblNombre.setText("Nombre Institucion:");

        lblRepresentante.setFont(new java.awt.Font("Agency FB", 0, 14));
        lblRepresentante.setText("Representante:");

        lblTelefono.setFont(new java.awt.Font("Agency FB", 0, 14));
        lblTelefono.setText("Telefono:");

        lblDireccion.setFont(new java.awt.Font("Agency FB", 0, 14));
        lblDireccion.setText("Direcion:");

        lblSector.setFont(new java.awt.Font("Agency FB", 0, 14));
        lblSector.setText("Sector:");

        lblFechaFundacion.setFont(new java.awt.Font("Agency FB", 0, 14));
        lblFechaFundacion.setText("Fecha Fundacion:");

        try {
            txtTelefono.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("(###)-###-####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }

        btnElegirFecha.setText("....");
        btnElegirFecha.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnElegirFechaActionPerformed(evt);
            }
        });

        txtDireccion.setColumns(20);
        txtDireccion.setRows(5);
        jScrollPane1.setViewportView(txtDireccion);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(lblRepresentante)
                    .addComponent(lblNombre)
                    .addComponent(lblTelefono)
                    .addComponent(lblFechaFundacion)
                    .addComponent(lblSector)
                    .addComponent(lblDireccion))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(txtRepresentante, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 204, Short.MAX_VALUE)
                            .addComponent(txtNombreIntitucion, javax.swing.GroupLayout.DEFAULT_SIZE, 204, Short.MAX_VALUE)
                            .addComponent(txtTelefono, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 204, Short.MAX_VALUE)
                            .addComponent(txtSector, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 204, Short.MAX_VALUE)
                            .addComponent(txtFechaFundacion, javax.swing.GroupLayout.DEFAULT_SIZE, 204, Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnElegirFecha, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 239, Short.MAX_VALUE))
                .addGap(116, 116, 116))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(19, 19, 19)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtNombreIntitucion, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblNombre))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtRepresentante, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblRepresentante))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtTelefono, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblTelefono))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtFechaFundacion, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblFechaFundacion)
                    .addComponent(btnElegirFecha))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtSector, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblSector))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lblDireccion)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 117, Short.MAX_VALUE))
                .addContainerGap())
        );

        tabInformacionPersonal.addTab("tab1", jPanel1);

        jPanel2.setBackground(new java.awt.Color(204, 204, 204));

        lblRangoEdades.setFont(new java.awt.Font("Agency FB", 0, 14));
        lblRangoEdades.setText("Rango de Edades:");

        try {
            txtRangoEdades.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("##-##")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        txtRangoEdades.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtRangoEdadesActionPerformed(evt);
            }
        });

        lblGenero.setFont(new java.awt.Font("Agency FB", 0, 14));
        lblGenero.setText("Genero:");

        lblNivelEconomico.setFont(new java.awt.Font("Agency FB", 0, 14));
        lblNivelEconomico.setText("Nivel Economico:");

        lblNivelEducativo.setFont(new java.awt.Font("Agency FB", 0, 14));
        lblNivelEducativo.setText("Nivel Educativo:");

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lblRangoEdades)
                    .addComponent(lblGenero)
                    .addComponent(lblNivelEducativo)
                    .addComponent(lblNivelEconomico))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(txtNivelEducativo, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 217, Short.MAX_VALUE)
                    .addComponent(txtGenero, javax.swing.GroupLayout.DEFAULT_SIZE, 217, Short.MAX_VALUE)
                    .addComponent(txtRangoEdades, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtNivelEconomico, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 217, Short.MAX_VALUE))
                .addContainerGap(146, javax.swing.GroupLayout.PREFERRED_SIZE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGap(27, 27, 27)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblRangoEdades)
                    .addComponent(txtRangoEdades, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblGenero)
                    .addComponent(txtGenero, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblNivelEconomico)
                    .addComponent(txtNivelEconomico, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblNivelEducativo)
                    .addComponent(txtNivelEducativo, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(165, Short.MAX_VALUE))
        );

        tabInformacionPersonal.addTab("tab2", jPanel2);

        btnAceptar.setText("Aceptar");
        btnAceptar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAceptarActionPerformed(evt);
            }
        });

        btnCancelar.setText("Cancelar");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(tabInformacionPersonal, javax.swing.GroupLayout.PREFERRED_SIZE, 467, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(165, 165, 165)
                        .addComponent(btnAceptar)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnCancelar)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(tabInformacionPersonal, javax.swing.GroupLayout.PREFERRED_SIZE, 347, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(11, 11, 11)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnAceptar, javax.swing.GroupLayout.DEFAULT_SIZE, 27, Short.MAX_VALUE)
                    .addComponent(btnCancelar, javax.swing.GroupLayout.DEFAULT_SIZE, 27, Short.MAX_VALUE))
                .addContainerGap())
        );

        tabInformacionPersonal.getAccessibleContext().setAccessibleName("Informacion General");
        tabInformacionPersonal.getAccessibleContext().setAccessibleDescription("Informacion General");
    }// </editor-fold>//GEN-END:initComponents

    private void btnElegirFechaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnElegirFechaActionPerformed
        Date fecha = seleccionarFechaFundacion();
							fechaFundacion = fecha;
							txtFechaFundacion.setText(String
									.valueOf(formatoFecha
											.format(fechaFundacion)));
    }//GEN-LAST:event_btnElegirFechaActionPerformed

    private void txtRangoEdadesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtRangoEdadesActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_txtRangoEdadesActionPerformed

    private void btnAceptarActionPerformed(java.awt.event.ActionEvent evt) {                                           
        // TODO add your handling code here:
    }                                          
    /*
    private void btnAceptarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAceptarActionPerformed
      
    }//GEN-LAST:event_btnAceptarActionPerformed
*/


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnAceptar;
    private javax.swing.JButton btnCancelar;
    private javax.swing.JButton btnElegirFecha;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JLabel lblDireccion;
    private javax.swing.JLabel lblFechaFundacion;
    private javax.swing.JLabel lblGenero;
    private javax.swing.JLabel lblNivelEconomico;
    private javax.swing.JLabel lblNivelEducativo;
    private javax.swing.JLabel lblNombre;
    private javax.swing.JLabel lblRangoEdades;
    private javax.swing.JLabel lblRepresentante;
    private javax.swing.JLabel lblSector;
    private javax.swing.JLabel lblTelefono;
    private javax.swing.JTabbedPane tabInformacionPersonal;
    private javax.swing.JTextArea txtDireccion;
    private javax.swing.JTextField txtFechaFundacion;
    private javax.swing.JTextField txtGenero;
    private javax.swing.JTextField txtNivelEconomico;
    private javax.swing.JTextField txtNivelEducativo;
    private javax.swing.JTextField txtNombreIntitucion;
    private javax.swing.JFormattedTextField txtRangoEdades;
    private javax.swing.JTextField txtRepresentante;
    private javax.swing.JTextField txtSector;
    private javax.swing.JFormattedTextField txtTelefono;
    // End of variables declaration//GEN-END:variables


    	private Date seleccionarFechaFundacion() {
		JCalendar calendar = new JCalendar();
		JDialog dialogo = new JDialog();
		dialogo.setTitle("Elija la Fecha En Que Se Fundo");
		dialogo.setModal(true);
		dialogo.setContentPane(calendar);
		dialogo.setSize(210, 169);
		dialogo.setVisible(true);
		return calendar.getDate();

	}


}
